<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <!-- import CSS -->
  <link rel="stylesheet" href="css/eui.css">
  <style>
    body{
      margin: 0;
      background-image: url("imgs/bg.jpg");
      background-size: cover;/*cover是专门用来设置背景全屏的样式*/
    }
    #app{
      text-align: center;
    }
    h1{
      font-size: 72px;
      color: rgb(0,150,215);
      margin-bottom: 0;
    }
    img{
      width: 100px;
    }
    h2{
      font-size: 32px;
      color: #0095d7;
      margin: 0;
    }
  </style>
</head>
<body>
<div id="app" >
  <h1>欢迎来到博客用户注册页面</h1>

  <h2>BlogRegistration</h2>
  <el-card style="width: 600px;height: 300px;margin: 0 auto;background-color: rgba(255,255,255,0.4)">
    <el-form style="width: 400px; margin: 30px auto "label-width="60px">
      <el-form-item label="用户名">
        <el-input type="text" v-model="user.username" placeholdel="请输入用户名"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input type="password" v-model="user.password" placeholdel="请输入用密码"></el-input>
      </el-form-item>
      <el-form-item label="昵称">
        <el-input type="text" v-model="user.nick" placeholdel="请输入昵称"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="reg()">注册</el-button>
        <el-button type="primary" >重置</el-button>
      </el-form-item>
    </el-form>
  </el-card>
  <!--<form action="">
    <input type="text" name="username" v-model="user.username" placeholder="用户名">
    <input type="password" name="password" v-model="user.password" placeholder="密码">
    <input type="text" name="nick" v-model="user.nick" placeholder="昵称">
    <input type="button" value="注册" @click="reg()">
  </form>-->
</div>
</body>
<script src="js/vue.min.js"></script>
<!-- import JavaScript -->
<script src="js/eui.js"></script>
<script src="js/axios.min.js"></script>
<script>
   let v = new Vue({
    el: '#app',
    data:{
        user: {
          username: "",
          password: "",
          nick: ""
        }
    },
     methods:{
      reg(){
        axios.post("/user/reg",v.user).then(function (response) {

            if (response.data==1){
              location.href="/";
              v.$message.success("注册成功!");
            } else if (response==2){
              v.$message.success("用户名已存在!");
            }
        })
      }

     }
  })
</script>
</html>